﻿using System.Runtime.InteropServices;
using UtilZ.Dotnet.AudioPlayer.Native;

namespace UtilZ.Dotnet.AudioPlayer.Player
{
    /// <summary>
    /// 播放设备信息
    /// </summary>
    public class SoundPlayingDeviceInfo
    {
        /// <summary>
        /// 播放设备标识
        /// </summary>
        public int DeviceId { get; private set; }

        /// <summary>
        /// 播放设备名称
        /// </summary>
        public string DeviceName { get; private set; }

        /// <summary>
        /// 播放设备驱动名称
        /// </summary>
        public string DriverName { get; private set; }

        /// <summary>
        /// Bass设备状态标识
        /// </summary>
        public BASSDeviceInfo Flags { get; private set; }


        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="deviceId">播放设备标识</param>
        /// <param name="bassDeviceInfo">Bass播放设备信息</param>
        internal SoundPlayingDeviceInfo(int deviceId, ref BASS_DEVICEINFO_INTERNAL bassDeviceInfo)
        {
            this.DeviceId = deviceId;
            this.DriverName = Marshal.PtrToStringAnsi(bassDeviceInfo.driver);
            this.DeviceName = Marshal.PtrToStringAnsi(bassDeviceInfo.name);
            this.Flags = bassDeviceInfo.flags;
        }

        /// <summary>
        /// 重写ToString
        /// </summary>
        /// <returns>String</returns>
        public override string ToString()
        {
            return this.DeviceName;
        }
    }
}
